//MainFrame类
//主窗体
//package socket;

import java.awt.Container;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

public class MainFrame extends JFrame{
	//界面宽度高度
	private static final int WIDTH = 300;
	private static final int HEIGHT = 600;
	private static JTextArea jText_read = new JTextArea();
	//
	private static MySocketController mySocketController = null;
	
	public MainFrame () {
		super();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(WIDTH, HEIGHT);
		this.getContentPane().setLayout(null);
		this.setResizable(false);
		addComponents(this.getContentPane());
	}
	
	private void addComponents(Container con) {
		
		jText_read.setBounds(0,0,WIDTH,HEIGHT);
		jText_read.setEditable(false);
		
		con.add(jText_read,null);
	}
	public String getContent_read(){
		return jText_read.getText();
	}
	
	public void setContent_read(String s){
		jText_read.setText(jText_read.getText()+"\n"+s);
	}
	
	
	public static void getError(String s){
		JOptionPane.showMessageDialog(null,s, 
		"警告", JOptionPane.ERROR_MESSAGE);
		
	}
	
	
	
	public void correspond(String s) throws IOException{
		while(true){
			String str = mySocketController.getContent();
			this.setContent_read(str);
		}
	}
	
}
